//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//

#include <windows.h>
#include <minshell.h>

void 
Desktop_ShellNotificationHook(
    DWORD dwNotify,
    LPVOID lpvParam
    )
{
    return;
}

BOOL 
Desktop_WindowProcHook(
    HWND hWnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam,
    LRESULT* lplResult
    )
{
    return FALSE;
}

int WINAPI WinMain(
    HINSTANCE hInstance, 
    HINSTANCE hPrevInstance, 
    LPWSTR lpCmdLine, 
    int nCmdShow
    )
{
    BOOL fSuccess = FALSE;

    //
    // Exit if shell is already running
    //
    if( FindWindow( CLASSNAME_DESKTOP, NULL ) )
    {
        return 0;
    }

    if( Desktop_Init( hInstance ) )
    {
        //
        // We call SignalStarted with our start-sequence ID 
        // to signal that we're done initializing. The ID is 
        // passed to us on the cmdline by the kernel when we 
        // are launched at startup from the HKLM\init key. 
        // If we don't call SignalStarted() apps that depend 
        // on us in the HKLM\init key will never start
        //
        SignalStarted( _wtol(lpCmdLine) );
        
        Desktop_CalibrateTouch();

        MSG msg;
        while( GetMessage( &msg, NULL, 0, 0 ) )
        {
            if( msg.message == WM_QUIT )
                break;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        fSuccess = TRUE;
    }
    Desktop_Uninit();

    return fSuccess ? 0 : -1;
}
